package com.yc.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.stream.Stream;

public enum StatusEnum {
    INVALID(0, "无效"),
    NORMAL(1, "正常");

    @EnumValue
    @JsonValue
    private final int value;
    private final String desc;

    public int getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    StatusEnum(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static StatusEnum toType(int value) {
        return Stream.of(StatusEnum.values())
                .filter(p -> p.value == value)
                .findAny()
                .orElse(null);
    }
}
